package com.hong.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hong.domain.Employee;
import com.hong.dto.QueryPageEmployeeDTO;
import com.hong.service.EmployeeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
* 员工记录表(employee)表控制层
*
* @author xxxxx
*/
@Api(value ="职工",tags = {"职工"})
@RestController
@RequestMapping("/employee")
public class EmployeeController {
/**
* 服务对象
*/
    @Autowired
    private EmployeeService employeeService;

    /**
    * 通过主键查询单条数据
    *
    * @param id 主键
    * @return 单条数据
    */
    @ApiOperation(value = "获取员工信息",tags = {"职工"})
    @GetMapping("getById/{id}")
    public Employee getById(@PathVariable Integer id) {
    return employeeService.getById(id);
    }

    @ApiOperation(value = "分页获取员工信息",tags = {"职工"})
    @GetMapping("page")
    public IPage<Employee> getPage(QueryPageEmployeeDTO param){
        return employeeService.getPage(param);
    }

    @ApiOperation(value = "修改名字")
    @PutMapping("update/name")
    public Integer updateNameById(Employee employee){
        return employeeService.updateNameById(employee);
    }

    @ApiOperation(value = "删除员工",tags = {"职工"})
    @DeleteMapping("delete/{id}")
    public boolean deleteById(@PathVariable Integer id){
        return employeeService.removeById(id);
    }

    @ApiOperation(value = "批量更新",tags = {"职工"})
    @PutMapping("update/batch")
    public boolean batchUpdateEmployee(@RequestBody List<Employee> list){
        return employeeService.updateBatchById(list);
    }




}
